using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for ManageCheckedOutBook
/// </summary>
public class ManageCheckedOutBook
{
    DatabaseAccess da = new DatabaseAccess();
    Library lib = new Library();

    //Checks out a book
    //jacquie 
    public void checkoutBook(CheckedOutBook book) 
    {
        da.checkOutBook(book);
    }

    //Checks in a book
    //jacquie
    public int checkInBook(String barcode)
    {
        int rowsAffected = da.checkInBook(barcode);
        return rowsAffected;
    }

    public void updateCheckedOutBook(CheckedOutBook book) 
    {
        da.updateCheckedOutBook(book);
    }

    public void checkinBook(String Barcode) { }//delete

    //for checkOutBooks.ascx
    //jacquie
    public SqlDataAdapter getBooksCheckedOut_LibrarianView(string personID)
    {
        return da.GetBooksCheckedOut_LibrarianView(personID);
    }

    //checks to see if a book is checked in for checkInBooks.ascx
    //Jacquie
    public Boolean checkedOutBookReturnedExists(string barcode)
    {
        Boolean exist = true;
        DatabaseAccess da = new DatabaseAccess();
        int ex = da.checkedOutBookReturnedExists(barcode);
        if (ex < 1)
            exist = false;
        return exist;
    }

    //checks to see if a book exists in checkedOutBook Table in for checkInBooks.ascx
    //Jacquie
    public Boolean checkedOutBookExists(string barcode)
    {
        Boolean exist = true;
        DatabaseAccess da = new DatabaseAccess();
        int ex = da.checkedOutBookExists(barcode);
        if (ex < 1)
            exist = false;
        return exist;
    }

    //get books checked out by patron - Elizabeth
    public SqlDataAdapter getCheckedOutBooks(int personID)
    {
        DatabaseAccess da = new DatabaseAccess();
        return da.getBooksCheckedOut(personID);
    }

    public SqlDataReader getAllBooksCheckedOut()
    {
        return null;
    }

    //checks to see if book has been reserved - Elizabeth
    public int isBookRenewable(String Barcode)
    {
        return da.isRenewable(Barcode);
    }

    public int isBookCheckedOut(String Barcode)
    {
        return da.isBookCheckedOut(Barcode);
    }

    //gets the details of a checked out book - Elizabeth
    public CheckedOutBook checkedOutBookDetails(string barcode)
    {
        return da.checkedOutBookDetails(barcode);
    }

    public DateTime getDate()
    {
        return da.getDate();
    }

    //get the closest due date of a patron's checked out books
    public DateTime getDueDate(int personID)
    {
        return da.getDueDate(personID);
    }
}
